<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <title>电子健康卡申请</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: "PingFang SC", "Helvetica Neue", Arial, sans-serif;
        }
        
        body {
            background-color: #f5f7fa;
            color: #333;
            display: flex;
            justify-content: center;
            padding: 20px 0;
        }
        
        .container {
            width: 750px;
            background-color: #fff;
            box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
            border-radius: 16px;
            overflow: hidden;
            position: relative;
        }
        
        header {
            background: linear-gradient(135deg, #4caf50, #2e7d32);
            color: white;
            padding: 30px 20px 20px;
            text-align: center;
            position: relative;
        }
        
        .logo {
            font-size: 24px;
            font-weight: bold;
            display: flex;
            align-items: center;
            justify-content: center;
            margin-bottom: 10px;
        }
        
        .logo i {
            margin-right: 10px;
            font-size: 28px;
        }
        
        .title {
            font-size: 20px;
            margin: 15px 0 10px;
        }
        
        .progress-container {
            display: flex;
            justify-content: space-between;
            padding: 30px 60px 20px;
            position: relative;
            margin-top: 20px;
        }
        
        .progress-step {
            display: flex;
            flex-direction: column;
            align-items: center;
            z-index: 2;
        }
        
        .step-circle {
            width: 36px;
            height: 36px;
            border-radius: 50%;
            background-color: #e0e0e0;
            color: #9e9e9e;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: bold;
            margin-bottom: 8px;
            border: 2px solid #e0e0e0;
        }
        
        .step-circle.active {
            background-color: #4caf50;
            color: white;
            border-color: #4caf50;
        }
        
        .step-circle.completed {
            background-color: #4caf50;
            color: white;
            border-color: #4caf50;
        }
        
        .step-title {
            font-size: 14px;
            color: #9e9e9e;
            text-align: center;
        }
        
        .step-title.active {
            color: #4caf50;
            font-weight: bold;
        }
        
        .progress-bar {
            position: absolute;
            top: 48px;
            left: 100px;
            right: 100px;
            height: 4px;
            background-color: #e0e0e0;
            z-index: 1;
        }
        
        .progress-fill {
            height: 100%;
            background-color: #4caf50;
            width: 0%;
            transition: width 0.5s ease;
        }
        
        .content {
            padding: 30px;
            min-height: 400px;
        }
        
        .section {
            display: none;
            animation: fadeIn 0.5s ease;
        }
        
        .section.active {
            display: block;
        }
        
        .health-code {
            background: linear-gradient(135deg, #4caf50, #2e7d32);
            border-radius: 16px;
            padding: 30px;
            color: white;
            text-align: center;
            box-shadow: 0 8px 20px rgba(76, 175, 80, 0.3);
            margin: 20px 0;
        }
        
        .code-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 30px;
        }
        
        .code-title {
            font-size: 22px;
            font-weight: bold;
        }
        
        .validity {
            background-color: rgba(255, 255, 255, 0.2);
            padding: 5px 15px;
            border-radius: 20px;
            font-size: 14px;
        }
        
        .qr-code {
            width: 200px;
            height: 200px;
            background-color: white;
            margin: 0 auto 30px;
            border-radius: 12px;
            display: flex;
            align-items: center;
            justify-content: center;
            position: relative;
            overflow: hidden;
        }
        
        .qr-code::before {
            content: "";
            position: absolute;
            width: 100%;
            height: 100%;
            background: 
                linear-gradient(45deg, transparent 48%, #4caf50 50%, transparent 52%),
                linear-gradient(-45deg, transparent 48%, #4caf50 50%, transparent 52%);
            background-size: 20px 20px;
        }
        
        .user-info {
            background-color: rgba(255, 255, 255, 0.15);
            padding: 15px;
            border-radius: 12px;
            margin-top: 20px;
        }
        
        .info-item {
            display: flex;
            justify-content: space-between;
            padding: 8px 0;
            border-bottom: 1px solid rgba(255, 255, 255, 0.2);
        }
        
        .info-item:last-child {
            border-bottom: none;
        }
        
        .info-label {
            font-weight: bold;
        }
        
        .sign-section {
            text-align: center;
        }
        
        .sign-icon {
            font-size: 80px;
            color: #4caf50;
            margin: 30px 0;
        }
        
        .sign-title {
            font-size: 24px;
            margin-bottom: 15px;
            color: #4caf50;
        }
        
        .sign-desc {
            font-size: 16px;
            color: #666;
            line-height: 1.6;
            margin-bottom: 30px;
        }
        
        .status-card {
            background-color: #f8f9fa;
            border-radius: 12px;
            padding: 25px;
            text-align: center;
            margin: 30px 0;
            border: 1px solid #e9ecef;
        }
        
        .status-icon {
            font-size: 48px;
            margin-bottom: 20px;
        }
        
        .status-icon.pending {
            color: #ff9800;
        }
        
        .status-icon.completed {
            color: #4caf50;
        }
        
        .status-text {
            font-size: 20px;
            margin-bottom: 15px;
            font-weight: bold;
        }
        
        .status-desc {
            color: #6c757d;
            margin-bottom: 20px;
        }
        
        .btn {
            display: inline-block;
            background-color: #4caf50;
            color: white;
            padding: 14px 35px;
            border-radius: 30px;
            font-size: 18px;
            font-weight: bold;
            text-decoration: none;
            cursor: pointer;
            border: none;
            transition: all 0.3s ease;
            box-shadow: 0 4px 10px rgba(76, 175, 80, 0.3);
        }
        
        .btn:hover {
            background-color: #3d8b40;
            transform: translateY(-2px);
            box-shadow: 0 6px 15px rgba(76, 175, 80, 0.4);
        }
        
        .btn:active {
            transform: translateY(0);
        }
        
        .btn-block {
            display: block;
            width: 100%;
            text-align: center;
            margin-top: 20px;
        }
        
        .form-group {
            margin-bottom: 25px;
        }
        
        .form-label {
            display: block;
            margin-bottom: 8px;
            font-weight: bold;
            color: #555;
            font-size: 16px;
        }
        
        .form-input {
            width: 100%;
            padding: 15px;
            border: 1px solid #ddd;
            border-radius: 10px;
            font-size: 16px;
            transition: border-color 0.3s;
        }
        
        .form-input:focus {
            border-color: #4caf50;
            outline: none;
            box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.2);
        }
        
        .info-text {
            background-color: #e8f5e9;
            border-left: 4px solid #4caf50;
            padding: 15px;
            border-radius: 0 8px 8px 0;
            margin: 25px 0;
            font-size: 14px;
            color: #2e7d32;
        }
        
        .footer {
            text-align: center;
            padding: 25px;
            color: #666;
            font-size: 14px;
            border-top: 1px solid #eee;
        }
        
        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(20px); }
            to { opacity: 1; transform: translateY(0); }
        }
        
        .success-message {
            text-align: center;
            padding: 30px;
        }
        
        .success-icon {
            font-size: 80px;
            color: #4caf50;
            margin-bottom: 20px;
        }
        
        .success-title {
            font-size: 24px;
            margin-bottom: 15px;
            color: #4caf50;
        }
        
        .success-desc {
            font-size: 16px;
            color: #666;
            line-height: 1.6;
            margin-bottom: 30px;
        }
        
        @media (max-width: 768px) {
            .container {
                width: 100%;
                border-radius: 0;
            }
            
            .progress-container {
                padding: 25px 30px 15px;
            }
            
            .content {
                padding: 20px;
            }
        }
    </style>
</head>
<body>
    <div class="container">
        <header>
            <div class="logo">
                <i class="fas fa-heartbeat"></i>
                健康中国
            </div>
            <div class="title">电子健康卡申请</div>
            
            <div class="progress-container">
                <div class="progress-bar">
                    <div class="progress-fill" id="progress-fill"></div>
                </div>
                
                <div class="progress-step">
                    <div class="step-circle" id="step1">1</div>
                    <div class="step-title" id="step1-title">身份验证</div>
                </div>
                
                <div class="progress-step">
                    <div class="step-circle" id="step2">2</div>
                    <div class="step-title" id="step2-title">签署协议</div>
                </div>
                
                <div class="progress-step">
                    <div class="step-circle" id="step3">3</div>
                    <div class="step-title" id="step3-title">完成注册</div>
                </div>
            </div>
        </header>
        
        <div class="content">
            <!-- 健康码展示 -->
            <div class="section" id="health-code-section">
                <div class="health-code">
                    <div class="code-header">
                        <div class="code-title">电子健康卡</div>
                        <div class="validity">有效期至: 2025-12-31</div>
                    </div>
                    
                    <div class="qr-code">
                        <i class="fas fa-qrcode" style="font-size: 100px; color: #4caf50; z-index: 2;"></i>
                    </div>
                    
                    <div class="user-info">
                        <div class="info-item">
                            <span class="info-label">姓名:</span>
                            <span>张三</span>
                        </div>
                        <div class="info-item">
                            <span class="info-label">身份证号:</span>
                            <span>310************012</span>
                        </div>
                        <div class="info-item">
                            <span class="info-label">卡号:</span>
                            <span>EHC202307210001</span>
                        </div>
                    </div>
                </div>
                
                <p class="info-text">
                    <i class="fas fa-info-circle"></i> 电子健康卡可在全国医疗机构使用，实现跨机构、跨区域就医一卡通。
                </p>
                
                <button class="btn btn-block" onclick="showSignSection()">
                    <i class="fas fa-sync-alt"></i> 重新申请
                </button>
            </div>
            
            <!-- 签署协议 -->
            <div class="section" id="sign-section">
                <div class="sign-section">
                    <div class="sign-icon">
                        <i class="fas fa-file-signature"></i>
                    </div>
                    <div class="sign-title">签署电子协议</div>
                    <div class="sign-desc">
                        根据国家卫生健康委员会要求，申请电子健康卡需要签署《电子健康卡使用协议》，请仔细阅读协议内容后签署。
                    </div>
                    
                    <div class="status-card" id="sign-status-card">
                        <!-- 状态内容由JS动态生成 -->
                    </div>
                    
                    <button class="btn" id="sign-action-btn">
                        <!-- 按钮文本由JS动态生成 -->
                    </button>
                </div>
            </div>
            
            <!-- 注册表单 -->
            <div class="section" id="register-section">
                <h2 class="sign-title">填写个人信息</h2>
                <p class="sign-desc">请填写真实信息完成电子健康卡注册</p>
                
                <div class="form-group">
                    <label class="form-label">姓名</label>
                    <input type="text" class="form-input" id="name" placeholder="请输入您的真实姓名">
                </div>
                
                <div class="form-group">
                    <label class="form-label">身份证号码</label>
                    <input type="text" class="form-input" id="id-card" placeholder="请输入您的身份证号码">
                </div>
                
                <div class="form-group">
                    <label class="form-label">手机号码</label>
                    <input type="tel" class="form-input" id="phone" placeholder="请输入您的手机号码">
                </div>
                
                <p class="info-text">
                    <i class="fas fa-shield-alt"></i> 我们承诺保护您的个人信息安全，所有信息仅用于电子健康卡注册
                </p>
                
                <button class="btn btn-block" onclick="registerHealthCard()">
                    <i class="fas fa-check-circle"></i> 提交注册
                </button>
            </div>
            
            <!-- 注册成功 -->
            <div class="section" id="success-section">
                <div class="success-message">
                    <div class="success-icon">
                        <i class="fas fa-check-circle"></i>
                    </div>
                    <div class="success-title">注册成功！</div>
                    <div class="success-desc">
                        您已成功注册电子健康卡，现在可以凭此卡在全国医疗机构使用，享受便捷的医疗服务。
                    </div>
                    
                    <button class="btn" onclick="showHealthCode()">
                        <i class="fas fa-qrcode"></i> 查看我的健康码
                    </button>
                </div>
            </div>
        </div>
        
        <div class="footer">
            <p>© 2023 国家卫生健康委员会 | 电子健康卡服务平台</p>
            <p>服务热线: 12320</p>
        </div>
    </div>

    <script>
        // 模拟用户状态
        const userState = {
            hasVuid: localStorage.getItem('hasVuid') === 'true',
            contractSent: localStorage.getItem('contractSent') === 'true',
            contractSigned: localStorage.getItem('contractSigned') === 'true',
            registered: localStorage.getItem('registered') === 'true'
        };
        
        // 初始化页面
        document.addEventListener('DOMContentLoaded', function() {
            updateProgress();
            
            if (userState.hasVuid && userState.registered) {
                showHealthCode();
            } else if (userState.contractSigned) {
                showRegisterSection();
            } else if (userState.contractSent) {
                showSignSection('sent');
            } else {
                showSignSection('not_sent');
            }
        });
        
        // 更新进度条
        function updateProgress() {
            const progressFill = document.getElementById('progress-fill');
            const step1 = document.getElementById('step1');
            const step2 = document.getElementById('step2');
            const step3 = document.getElementById('step3');
            const step1Title = document.getElementById('step1-title');
            const step2Title = document.getElementById('step2-title');
            const step3Title = document.getElementById('step3-title');
            
            // 重置所有步骤
            step1.className = 'step-circle';
            step2.className = 'step-circle';
            step3.className = 'step-circle';
            step1Title.className = 'step-title';
            step2Title.className = 'step-title';
            step3Title.className = 'step-title';
            
            if (userState.registered) {
                // 已完成注册
                progressFill.style.width = '100%';
                step1.className = 'step-circle completed';
                step2.className = 'step-circle completed';
                step3.className = 'step-circle completed';
                step1Title.className = 'step-title active';
                step2Title.className = 'step-title active';
                step3Title.className = 'step-title active';
            } else if (userState.contractSigned) {
                // 已签署协议
                progressFill.style.width = '66%';
                step1.className = 'step-circle completed';
                step2.className = 'step-circle completed';
                step3.className = 'step-circle active';
                step1Title.className = 'step-title active';
                step2Title.className = 'step-title active';
                step3Title.className = 'step-title active';
            } else if (userState.contractSent) {
                // 已发送合同
                progressFill.style.width = '33%';
                step1.className = 'step-circle completed';
                step2.className = 'step-circle active';
                step1Title.className = 'step-title active';
                step2Title.className = 'step-title active';
            } else {
                // 未开始
                progressFill.style.width = '0%';
                step1.className = 'step-circle active';
                step1Title.className = 'step-title active';
            }
        }
        
        // 显示健康码
        function showHealthCode() {
            hideAllSections();
            document.getElementById('health-code-section').classList.add('active');
            updateProgress();
        }
        
        // 显示签署协议部分
        function showSignSection(status = 'not_sent') {
            hideAllSections();
            const signSection = document.getElementById('sign-section');
            const statusCard = document.getElementById('sign-status-card');
            const actionBtn = document.getElementById('sign-action-btn');
            
            signSection.classList.add('active');
            
            if (status === 'not_sent') {
                statusCard.innerHTML = `
                    <div class="status-icon">
                        <i class="fas fa-file-medical"></i>
                    </div>
                    <div class="status-text">未签署协议</div>
                    <div class="status-desc">您需要签署电子健康卡使用协议后才能申请电子健康卡</div>
                `;
                
                actionBtn.innerHTML = '<i class="fas fa-pen"></i> 去签署';
                actionBtn.onclick = sendContract;
            } else if (status === 'sent') {
                statusCard.innerHTML = `
                    <div class="status-icon pending">
                        <i class="fas fa-hourglass-half"></i>
                    </div>
                    <div class="status-text">待签署</div>
                    <div class="status-desc">我们已将电子协议发送到您的手机，请及时签署</div>
                `;
                
                actionBtn.innerHTML = '<i class="fas fa-check"></i> 我已签署';
                actionBtn.onclick = completeSigning;
            }
            
            updateProgress();
        }
        
        // 显示注册部分
        function showRegisterSection() {
            hideAllSections();
            document.getElementById('register-section').classList.add('active');
            updateProgress();
        }
        
        // 显示成功页面
        function showSuccess() {
            hideAllSections();
            document.getElementById('success-section').classList.add('active');
            updateProgress();
        }
        
        // 隐藏所有部分
        function hideAllSections() {
            const sections = document.querySelectorAll('.section');
            sections.forEach(section => {
                section.classList.remove('active');
            });
        }
        
        // 发送合同
        function sendContract() {
            userState.contractSent = true;
            localStorage.setItem('contractSent', 'true');
            showSignSection('sent');
            
            // 模拟发送合同
            setTimeout(() => {
                alert('电子合同已发送到您的手机，请及时签署！');
            }, 500);
        }
        
        // 完成签署
        function completeSigning() {
            userState.contractSigned = true;
            localStorage.setItem('contractSigned', 'true');
            showRegisterSection();
            
            // 模拟签署完成
            setTimeout(() => {
                alert('电子合同签署成功！');
            }, 500);
        }
        
        // 注册健康卡
        function registerHealthCard() {
            const name = document.getElementById('name').value;
            const idCard = document.getElementById('id-card').value;
            const phone = document.getElementById('phone').value;
            
            if (!name || !idCard || !phone) {
                alert('请填写完整的个人信息！');
                return;
            }
            
            if (!/^\d{17}[\dXx]$/.test(idCard)) {
                alert('请输入有效的身份证号码！');
                return;
            }
            
            if (!/^1[3-9]\d{9}$/.test(phone)) {
                alert('请输入有效的手机号码！');
                return;
            }
            
            // 保存注册状态
            userState.hasVuid = true;
            userState.registered = true;
            localStorage.setItem('hasVuid', 'true');
            localStorage.setItem('registered', 'true');
            
            showSuccess();
        }
    </script>
</body>
</html>